# -*- coding: utf-8 -*-
"""
@Time: 2022/2/19 10:41
@Author: jins
@File: 6.py
@Introduction: 
"""
from common import requests_api


def request_batch():
    device_id = 100000001
    for i in range(202210001, 202210011):
        device_id_temp = device_id
        for j in range(0, 11):
            if j == 0:
                parentDeviceId = -1
                rootDeviceId = -1
                device_code = str(i)
            else:
                parentDeviceId = device_id_temp
                rootDeviceId = device_id_temp
                device_code = str(i) + '_' + str(j)
            request_body = {
                "extTypeCode": "test_info",
                "parentDeviceId": parentDeviceId,
                "rootDeviceId": rootDeviceId,
                "extData": {
                    "node_type": 1,
                    "device_name": "test",
                    "device_id": device_id,
                    "device_code": device_code
                }
            }
            requests_api.auto_request(url='10.0.17.17:8802/device/addDevice/v1', body=request_body)
            device_id += 1


def add_base_device():
    for i in range(202210001, 202230001):
        request_body = {
            "extTypeCode": "xnyz",
            "parentDeviceId": "-1",
            "rootDeviceId": "-1",
            "extData": {
                "node_type": 1,
                "device_name": '设备' + str(i),
                "device_code": str(i),
                "collect_frequence": "mi5",
                "remark": 'test0223'
            }
        }
        requests_api.auto_request(url='10.0.17.17:8802/device/addDevice/v1', body=request_body)


if __name__ == '__main__':
    # request_batch()
    add_base_device()
